//
//  InstallationDetailSystemDetail.swift
//  ezyform
//
//  Created by MoennigQ on 12/12/2016.
//  Copyright © 2016 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import HandyJSON

enum GridConnectedValue: String {
    case onGrid = "on_grid"
    case offGrid = "off_grid"
}
enum GridConnectedName: String {
    case offGrid = "Off-Grid"
    case onGrid = "On-Grid"
}
enum InstallationTypeValue: String {
    case New = "new_system"
    case Replacement = "replacement_system"
    case Extension = "extension_system"
    case Additional = "additional_system"
    case none = ""
}

enum InstallationTypeName: String {
    case New = "New"
    case Replacement = "Replacement"
    case Extension = "Extension"
    case Additional = "Additional"
}
enum HeaterInstallationTypeName: String {
    case NewBuilding = "New buliding"
    case ReplacedElectricHeater = "Replace electric water heater"
    case ReplacedSolarWarterHeater = "Replace solar water heater"
    case FirstSolarWaterHeaterAtExistingBuilding = "1st installation on existing building"
    case ReplaceGasWaterHeater = "Replace gas water heater"
    case Other = "Other"
}
enum HeaterInstallationTypeValue: String {
    case NewBuilding = "new_building"
    case ReplacedElectricHeater = "replaced_electric_heater"
    case ReplacedSolarWarterHeater = "replaced_solar_water_heater"
    case FirstSolarWaterHeaterAtExistingBuilding = "first_solar_water_heater_at_existing_building"
    case ReplaceGasWaterHeater = "replace_gas_water_heater"
    case Other = "other"
    case None = ""
}

struct InstallationDetailSystemDetail: HandyJSON {
    var installation_type: String = ""//new_system,replacement_system,additional_system,extension_system
    var installation_type_title: String = ""
    var installation_date: String = ""
    var panel_brand: String = ""
    var panel_model: String = ""
    var inverter_manufacture: String = ""
    var inverter_series: String = ""
    var inverter_model: String = ""
//    var number_inverters: String = ""
    var type_of_connection: String = ""
    var system_mounting_type: String = ""
//    var number_panels: String = ""
    var watts_per_panel: String = ""
    var rated_output: String = ""
    var rec_quantity: String = ""
    var complete_unit: String = ""
    var additional_upgrade_system_details: String = ""
    var install_additional_information: String = ""
    var panels = [InstallationDetailSystemDetailForPanelModel]()
    var inverters = [InstallationDetailSystemDetailForInverterModel]()
    var batteries = [InstallationDetailSystemDetailForBatteryModel]()
    //panels的总计划数量
    var panel_plant_count: Int {
        var cnt: Int64 = 0
        _ = self.panels.map({cnt += $0.number_panels})
        return Int(cnt)
    }
    //inverters的总计划数量
    var inverter_plant_count: Int {//tank ，inverter共用,且SWH只有tank，PVD只有Inverter
        //inverter
        var count: Int64 = 0
        _ = self.inverters.map({count += $0.number_inverters})
        _ = self.heaters.map({count += $0.number_heaters})
        return Int(count)
    }
    var connected_type: String = ""//on_grid, off_grid
    var is_battery: Bool = false//是否有电池
    //Solar和Heater共用的字段
    var deemed_years: String = ""
    //Heater 热时期的字段
    var second_hand_flg: Bool = false//为 true 表示是二手
    var multi_heater_flg: Bool = false//为 true 表示装有多个热水器
    var heater_installation_type: String = ""//["new_building", "replaced_electric_heater", "replaced_solar_water_heater", "first_solar_water_heater_at_existing_building", "replace_gas_water_heater", "other"]
    var heater_installation_type_title: String = ""
    var additional_capacity_details: String = ""
    var quantity: String = ""
    var heaters = [InstallationDetailSystemDetailForHeaterModel]()
    
}
